package com.ccys.cms.controller.consultation;


import com.ccys.cms.service.consultation.BookingConsultNoteService;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.web.productAndService.NumEnum;
import com.ccys.db.entity.TblBookingConsultNote;
import com.ccys.db.vo.consultation.BookingConsultNoteVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "问诊订单列表详情Post Consult Notes")
@RequestMapping("consultation")
public class ConsultationDetailPostConsultNotes {

    @Resource
    private BookingConsultNoteService service;

    @PostMapping("bookingConsultNote")
    @ApiOperation("新增")
    @Transactional
    public ResponseResult insert(TblBookingConsultNote model) {

        int i = service.insertOrUpdate(model);
        return ResponseResult.update(i);
    }


    @PutMapping("bookingConsultNote")
    @ApiOperation("修改")
    @Transactional
    public ResponseResult update(TblBookingConsultNote model) {

        int i = service.insertOrUpdate(model);
        return ResponseResult.update(i);
    }


    @GetMapping("bookingConsultNote/detail")
    @ApiOperation("根据id查询")
    public ResponseResult<TblBookingConsultNote, Object> getById(String id) {

        return ResponseResult.success(service.findEntityById(id));
    }


    @DeleteMapping("bookingConsultNote")
    @ApiOperation("根据Id删除")
    @Transactional
    public ResponseResult delete(String id) {

        TblBookingConsultNote model = new TblBookingConsultNote();
        model.setId(id);
        model.setDelFlag(NumEnum.DEL.getCode());
        int i = service.updateEntityById(model);
        return ResponseResult.update(i);
    }


    @GetMapping("bookingConsultNote")
    @ApiOperation(value = "查询分页")
    public ResponseResult<PageInfo<BookingConsultNoteVo>, Object> getPage(String bookingId) {
        return service.getPage(bookingId);
    }

}
